package cn.tedu.basic;
//测试  匿名内部类
public class InnerClass2 {
    public static void main(String[] args) {
        Get g =new Get();
        g.Night();
        new Get().Night();
        Make m =new Get();
        m.Night();
        //匿名内部类
        new Make(){
            @Override
            public void Night() {
                System.out.println("every day !");
            }
        }.Night();//调用方法

        //
       Teacher t = new Teacher(){

            @Override
            public void make() {
                System.out.println("love !");
            }

            @Override
            public void wash() {
                System.out.println("with me !");
            }
        };//只能调用一个方法
        t.make();
        t.wash();//创建对象，
        new Doctor(){

            @Override
            public void eat() {
                System.out.println("fish");
            }

            @Override
            public void work() {
                System.out.println("good");
            }
        }.eat();//只可以调用一个方法
        //
       Doctor d = new Doctor(){

            @Override
            public void eat() {
                System.out.println("apple");
            }

            @Override
            public void work() {
                System.out.println("nice");
            }
            public void sleep(){
                System.out.println("every night !");
            }
        };
       d.eat();
       d.work();
       d.sleep();
       KongJie KJ =new KongJie(){

           @Override
           void make() {
               System.out.println("love");
           }
           public  void get(){}
           @Override
           public void wash() {
               System.out.println("with me");
           }
       };
        KJ.make();
        KJ.get();
        KJ.wash();
    }
}
interface Make{
    public static void Love(){

    }
    void Night();
}
class Get implements Make{
    public static void Love(){

    }
    public void Night(){
        System.out.println("every day !");
    }
}
//
interface Teacher{
    void make();
    void wash();
}
class Student implements Teacher{

    @Override
    public void make() {
        System.out.println("love !");
    }

    @Override
    public void wash() {
        System.out.println("with me !");
    }
}
abstract class Doctor{
    abstract public void eat();//抽象的方法不需要{}
    public void sleep(){
    }
     public abstract void work();
}
abstract class KongJie{
    abstract void make();
    public void get(){};
    public abstract void wash();
}